home *** CD-ROM | disk | FTP | other *** search
/ NT Sources / Infomagic - NT Source Volume 1 (Disc 1 of 2).iso / network / pcdctrla.exe / PCDCTRL.EXE / PCDPROT.TPU < prev    next >
Text File  |  1997-09-08  |  6KB  |  149 lines

  1. !+++
  2. ! PCDUO_PROTOCOL_INI.TPU - Edit the NDIS PROTOCOL.INI file for PC-Duo
  3. !
  4. ! v3.02 16-May-96 DB  - Updated to support Windows 95 NetBEUI
  5. !---
  6.  
  7. ! We only edit one section: [NetBEUI], to increase the number of SESSIONS and
  8. ! NCBS. These changes are only done if the LANABASE=value is 0 (zero). This
  9. ! makes NetBEUI the default NetBIOS adapter for PC-Duo.
  10.  
  11. PROCEDURE PCD_update_protocol ();
  12.  
  13.     ! Declare some local variables - initialised to zero
  14.  
  15.     LOCAL   PCD_lanabase,           ! The NetBEUI LANABASE= value (string)
  16.             PCD_old_ncbs,           ! The current NCBS value (string)
  17.             PCD_old_sessions,       ! The current SESSIONS value (string)
  18.             PCD_new_ncbs,           ! The new NCBS value (integer)
  19.             PCD_new_sessions,       ! The new SESSIONS value (integer)
  20.             PCD_section_name,       ! Holds the name of the NetBEUI section
  21.             PCD_section_range,      ! Used to detect or map file sections
  22.             PCD_wfw_version,        ! Holds the [network.setup] version= value
  23.             PCD_whitespace_pattern; ! Pattern allowing leading whitespace
  24.  
  25.     ! Use a pattern so we get the right values
  26.     ! This allows leading whitespace, but nothing else before the keyword.
  27.  
  28.     PCD_whitespace_pattern := (LINE_BEGIN | (LINE_BEGIN + SPAN (" " + ASCII (9))));
  29.  
  30.     ! See if we are running Windows for Workgroups by picking up the version
  31.     ! string from the [network.setup] section. If this section is not present,
  32.     ! then this isn't a WFW PROTOCOL.INI. If the value is 0x3100, it is 3.1.
  33.     ! If it is 0x3110, it is 3.11
  34.  
  35.     PCD_wfw_version := LUT_win_get_value ("[network.setup]", (PCD_whitespace_pattern + "version="));
  36.  
  37.     If ((PCD_wfw_version <> 0)
  38.     AND (PCD_wfw_version <> ""))
  39.     Then
  40.         MESSAGE (FAO ("Windows for Workgroups version <!AS> recognised", PCD_wfw_version));
  41.  
  42.         PCD_new_ncbs     := 48;
  43.         PCD_new_sessions := 16;
  44.     Else
  45.         MESSAGE ("Windows for Workgroups not recognised");
  46.  
  47.         PCD_new_ncbs     := 24;
  48.         PCD_new_sessions := 12;
  49.     Endif;
  50.  
  51.     ! Look for a [NETBEUI] (3.11) or a {MS$NETBEUI] (3.1) section
  52.     ! PATHWORKS 5 also uses [NETBEUI] so we want to catch this too.
  53.  
  54.     PCD_section_name := "[MS$NETBEUI]";
  55.  
  56.     PCD_section_range := LUT_create_range (LINE_BEGIN + PCD_section_name, LINE_BEGIN + "[");
  57.  
  58.     If (PCD_section_range = 0)
  59.     Then
  60.         PCD_section_name  := "[NETBEUI]";
  61.         PCD_section_range := LUT_create_range (LINE_BEGIN + PCD_section_name, LINE_BEGIN + "[");
  62.     Endif;
  63.  
  64.     ! Windows 95 uses [NETBEUI$], but it is mostly configured through the
  65.     ! Registry. We can't change that with LANutil.
  66.  
  67.     If (PCD_section_range = 0)
  68.     Then
  69.         PCD_section_name  := "[NETBEUI$]";
  70.         PCD_section_range := LUT_create_range (LINE_BEGIN + PCD_section_name, LINE_BEGIN + "[");
  71.     Endif;
  72.  
  73.     ! If no sections were found, then there is nothing for us to do here.
  74.  
  75.     If (PCD_section_range <> 0)
  76.     Then
  77.  
  78.         ! Pick up the LANABASE value from this section. If it is missing,
  79.         ! or set to zero, then we check the NCBS and SESSIONS values.
  80.  
  81.         PCD_lanabase := LUT_win_get_value (PCD_section_name, (PCD_whitespace_pattern + "LANABASE"), PCD_section_range);
  82.  
  83.         If ((PCD_lanabase = 0)
  84.         OR  (PCD_lanabase = "0"))
  85.         Then
  86.  
  87.             ! Now, look for the SESSIONS and NCBS lines in the section. Use the
  88.             ! whitespace pattern to make sure that we get the right values, and
  89.             ! the optional range parameter to limit the search.
  90.  
  91.             PCD_old_ncbs     := LUT_win_get_value (PCD_section_name, (PCD_whitespace_pattern + "NCBS"),     PCD_section_range);
  92.             PCD_old_sessions := LUT_win_get_value (PCD_section_name, (PCD_whitespace_pattern + "SESSIONS"), PCD_section_range);
  93.  
  94.             ! Check the NCBS value first. The correct value to use depends upon
  95.             ! whether we are running Bridge, Control, and Slave on the same PC.
  96.             ! We can't tell this from this file alone. Assume we are running all
  97.             ! of them for now. If it is not present, empty, or less than
  98.             ! PCD_new_ncbs, increase the value.
  99.  
  100.             If ((PCD_old_ncbs = 0)
  101.             OR  (PCD_old_ncbs = "")
  102.             OR (INT (PCD_old_ncbs) < PCD_new_ncbs))
  103.             Then
  104.                 MESSAGE (FAO ("Increasing NCBS to !UL", PCD_new_ncbs));
  105.                 LUT_spaceline_replace_add ("NCBS", "NCBS=" + STR (PCD_new_ncbs), PCD_section_range);
  106.             Else
  107.                 MESSAGE (FAO ("Current !AS NCBS value is !AS", PCD_section_name, PCD_old_ncbs));
  108.             Endif;
  109.  
  110.             ! Check the SESSIONS value next. Make sure that this is at least 16,
  111.             ! though the correct value to use will depend upon how many NetBIOS
  112.             ! applications are running. Increase this if you have difficulty
  113.             ! making connections to network resources.
  114.  
  115.             If ((PCD_old_sessions = 0)
  116.             OR  (PCD_old_sessions = "")
  117.             OR (INT (PCD_old_sessions) < PCD_new_sessions))
  118.             Then
  119.                 MESSAGE (FAO ("Increasing SESSIONS to !UL", PCD_new_sessions));
  120.                 LUT_spaceline_replace_add ("SESSIONS", "SESSIONS=" + STR (PCD_new_sessions), PCD_section_range);
  121.             Else
  122.                 MESSAGE (FAO ("Current !AS SESSIONS value is !AS", PCD_section_name, PCD_old_sessions));
  123.             Endif;
  124.         Else
  125.             MESSAGE (FAO ("Skipping !AS LANABASE !AS", PCD_section_name, PCD_lanabase));
  126.         Endif;
  127.     Else
  128.         MESSAGE (FAO ("!AS section not found in PROTOCOL.INI file. Exiting.", PCD_section_name));
  129.         Quit;
  130.     Endif;
  131. Endprocedure;
  132.  
  133.  
  134. LUT_start_edit ();      ! This reads the file (if it exists), creates a buffer,
  135.                         ! and positions us at the top of the buffer
  136.  
  137. IF LUT_buffer_empty
  138. THEN
  139.     quit;               ! Error - the input file must exist!
  140. ENDIF;
  141.  
  142. ! Do the update
  143.  
  144. PCD_update_protocol ();
  145.  
  146. ! And now perform 'standard' finishing functions...
  147.  
  148. LUT_finish_edit ();
  149.